<template>
  <d2-container>
  <div>
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-select v-model="searchList.search" placeholder="请选择" size="mini" style="width: 150px;" height="250" @change="onChangesele">
          <el-option v-for="item in searchs" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input :disabled="isdis" clearable placeholder="请输入内容" size="mini" v-model="searchList.searchValue"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="mini" @click="init">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" border :data="tableData" style="width: 100%" header-align="center">
      <el-table-column type="index" label="序号" width="60" align="center"></el-table-column>
      <el-table-column prop="id" label="编号" width="" align="center"></el-table-column>
      <el-table-column prop="task_shopname" label="店铺" width="200" align="center"></el-table-column>
      <el-table-column prop="baby_id" label="宝贝ID" width="120" align="center">
          <template slot-scope="props">
              <a target="_blank" :href="'https://detail.tmall.com/item.htm?id=' + props.row.baby_id">{{props.row.baby_id}}</a>
          </template>
      </el-table-column>
      <el-table-column prop="brushhands_tbname" label="旺旺" width="120" align="center"></el-table-column>
      <el-table-column prop="task_goodsname" label="产品名称" width="260" align="center">
        <template slot-scope="props">
          <a target="_blank" :href="'https://detail.tmall.com/item.htm?id=' + props.row.baby_id">{{props.row.task_goodsname}}</a>
        </template>
      </el-table-column>
      <el-table-column prop="task_order" label="订单号" width="180" align="center"></el-table-column>
      <el-table-column prop="brushhands_group" label="组" width="" align="center"></el-table-column>
      <el-table-column prop="task_class" label="任务类型" width="" align="center">
        <template slot-scope="props">
          <p style="text-align: center;">{{props.row.task_class == 'pt' ? '普通单':(props.row.task_class=='ll'?'浏览单':'评价单')}}</p>
        </template>
      </el-table-column>
      <el-table-column prop="task_bjmoney" label="本金" width="" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.task_bjmoney * 1}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="create_time" label="支付时间" width="160" align="center">
        <template slot-scope="props">
          <span>{{ props.row.create_time }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="task_refandstatus" label="退款状态" width="120" align="center"></el-table-column>
      <!-- <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
      <el-table-column prop="task_time" label="订单时间" width="160" align="center"></el-table-column>
      <el-table-column prop="user" label="用户" width="100" align="center"></el-table-column>
      <el-table-column prop="shop" label="店铺" width="140" align="center"></el-table-column>
      <el-table-column prop="taobao" label="旺旺" width="120" align="center"></el-table-column>
      <el-table-column prop="babyName" label="产品名称" width="120" align="center">
        <template slot-scope="props">
          <a target="_blank" :href="'https://detail.tmall.com/item.htm?id=' + props.row.babyId">{{props.row.babyName}}</a>
        </template>
      </el-table-column>
      <el-table-column prop="insuranceMoney" label="是否购买保险" width="120" align="center">
        <template slot-scope="props">
          <p style="text-align: center;">{{props.row.insuranceMoney == 0 ? '否':'是'}}</p>
        </template>
      </el-table-column>
      <el-table-column prop="order" label="订单号" width="170" align="center"></el-table-column>
      <el-table-column prop="addTime" label="申请时间" width="160" align="center"></el-table-column>
      <el-table-column prop="refund_time" label="退款时间" width="160" align="center"></el-table-column>
      <el-table-column prop="principal" label="本金" width="80" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.money * 1}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="comMoney" label="佣金" width="80" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.sjComMoney * 1}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="refund_status" label="退款状态" width="90" align="center"></el-table-column>
      <el-table-column prop="refund_handle_finally" label="处理进度" width="150" align="center">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" v-if="scope.row.status == 0 && scope.row.status2 == 0">处理中</el-button>
          <el-button size="mini" type="primary" v-else>已处理</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="" label="处理结果" width="100" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.status == 1 && scope.row.status2 == 1">已通过</span>
          <span style="color: red;" v-else>不通过</span>
        </template>
      </el-table-column>
      <el-table-column prop="" label="备注" width="150" align="center">
        <template slot-scope="scope">
          <p>{{scope.row.desc + scope.row.desc2}}</p>
        </template>
      </el-table-column> -->
    </el-table>
    <el-pagination :page-size="20" :current-page="searchList.pn" layout="total,prev, pager, next"
                   :total="searchList.total" @current-change="pnChange" v-if="searchList.total > 20">
    </el-pagination>
  </div>
  </d2-container>
</template>

<script>
import { complaintlist } from '../../../api/api'
  export default {
    name: "AdminRefundList",
    data(){
      return{
        data:[],
        tableData: [],
        searchList: {
          search: "user",
          searchValue: "",
          pn: 1,
          total: 0
        },
        loading:true,
        searchs: [
          {
              value: "user",
              label: "全部"
          },
          {
              value: "babyId",
              label: "宝贝ID"
          },
          {
              value: "shop",
              label: "店铺"
          },
          {
              value: "order",
              label: "订单号"
          },
          {
              value: "refund",
              label: "退款"
          },
          {
              value: "tb_name",
              label: "旺旺号"
          }
        ],
        isdis:false
      }
    },
    methods:{
      //获取用户信息
      getUser(){
        userinfo().then(res=>{
          if(res.Status == 200){
            this.$emit('getMoney',res.Data.money)
          }else{
            this.$message.error(res.Message)
          }
        })
      },
      pnChange(pn) {
        this.searchList.pn = pn;
        this.init();
      },
      //筛选下改变
      onChangesele(val){
        console.log('选择',val)
        if(val == 'refund'){
          this.searchList.searchValue = 'NO_REFUND'
          this.isdis = true
        }
      },
      //获取列表
      init() {
        let _this = this
        var params = {
          Tfcondition: _this.searchList.search,
          Wherecondition:_this.searchList.searchValue,
          Page: _this.searchList.pn,
        }
        complaintlist(params).then(res=>{
          console.log('res.Data',res.Data)
            _this.loading = false
          if(res.Status == 200){
            let temp = res.Data
            let ipos
            temp.forEach(ele => {
              ipos = ele.create_time.indexOf("+")
              ele.create_time = ele.create_time.replace(/T/g," ").substring(0,ipos)
            })
            this.tableData = temp
            _this.searchList.total = parseInt(res.Count);
          }else{
            this.$message.error(res.Message)
          }
          console.log('this.tableData',this.tableData)
        })
      },
    },
    created(){
      this.init()
      this.getUser()
    }
  }
</script>

<style scoped>

</style>
